﻿<!DOCTYPE html>
<html ng-app="demoApp" lang="en">
<head>
    <title id='Description'>AngularJS Chart Polar Axis Example</title>
   <meta name="description" content="This is an example of AngularJS Chart. Chart Polar Series." />	
    <link rel="stylesheet" type="text/css" href="../../../jqwidgets/styles/jqx.base.css" />
    <script type="text/javascript" src="../../../scripts/angular.min.js"></script> <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxslider.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxchart.core.js"></script><script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdraw.js"></script>
    <script type="text/javascript" src="../../../scripts/demos.js"></script>
    <script type="text/javascript">
        var demoApp = angular.module("demoApp", ["jqwidgets"]);
        demoApp.controller("demoController", function ($scope) {
            var chart;
            // prepare the data
            var source =
            {
                datatype: "tab",
                datafields: [
                    { name: 'Year' },
                    { name: 'HPI' },
                    { name: 'BuildCost' },
                    { name: 'Population' },
                    { name: 'Rate' }
                ],
                url: '../../sampledata/homeprices.txt'
            };

            var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });

            // prepare jqxChart settings
            var settings = {
                created: function (args) {
                    chart = args.instance;
                },
                title: "U.S. Real Home Price vs Building Cost Indeces (1950-2010)",
                description: "Source: http://www.econ.yale.edu/~shiller/data.htm",
                enableAnimations: true,
                showLegend: true,
                padding: { left: 5, top: 5, right: 5, bottom: 5 },
                titlePadding: { left: 0, top: 0, right: 0, bottom: 5 },
                source: dataAdapter,
                xAxis:
                    {
                        dataField: 'Year',
                        unitInterval: 10,
                        maxValue: 2010,
                        valuesOnTicks: true
                    },
                colorScheme: 'scheme01',
                seriesGroups:
                    [
                        {
                            polar: true,
                            startAngle: 0,
                            radius: 120,
                            type: 'splinearea',
                            valueAxis:
                            {
                                description: 'Index Value',
                                formatSettings: { decimalPlaces: 0 }
                            },
                            series: [
                                    { dataField: 'HPI', displayText: 'Real Home Price Index', opacity: 0.7, lineWidth: 1, radius: 2, lineWidth: 2 },
                                    { dataField: 'BuildCost', displayText: 'Building Cost Index', opacity: 0.7, lineWidth: 1, radius: 2, lineWidth: 2 }
                            ]
                        }
                    ]
            };


            // create the chart
            $scope.chartSettings = settings;


            // start angle slider
            $scope.sliderAngleSettings = { width: 240, min: 0, max: 360, step: 1, ticksFrequency: 20, mode: 'fixed' };

            $scope.sliderStartAngleChange = function (event) {
                var value = event.args.value;
                if (chart) {
                    chart.seriesGroups[0].startAngle = value;
                    chart.update();
                }
            };

            // radius slider
            $scope.sliderRadiusSettings = { width: 240, min: 80, max: 140, value: 120, step: 1, ticksFrequency: 20, mode: 'fixed' };

            $scope.sliderRadiusChange = function (event) {
                var value = event.args.value;
                if (chart) {
                    chart.seriesGroups[0].radius = value;
                    chart.update();
                }
            };

            // color scheme drop down
            var colorsSchemesList = ["scheme01", "scheme02", "scheme03", "scheme04", "scheme05", "scheme06", "scheme07", "scheme08"];
            $scope.dropDownColorsSettings = { source: colorsSchemesList, selectedIndex: 2, width: '200', height: '25', dropDownHeight: 100 };

            $scope.dropDownColorsChange = function (event) {
                var value = event.args.item.value;
                if (chart) {
                    chart.colorScheme = value;
                    chart.update();
                }
            };

            // series type drop down
            var seriesList = ["splinearea", "spline", "column", "scatter", "stackedcolumn", "stackedsplinearea", "stackedspline"];
            $scope.dropDownSeriesSettings = { source: seriesList, selectedIndex: 0, width: '200', height: '25', dropDownHeight: 100 };

            $scope.dropDownSeriesSelect = function (event) {
                var args = event.args;
                if (args) {
                    var value = args.item.value;

                    if (chart) {
                        chart.seriesGroups[0].type = value;
                        chart.update();
                    }
                }
            };
        });
    </script>
</head>
<body ng-controller="demoController">
    <jqx-chart jqx-settings="chartSettings" style="width: 850px; height: 500px">
    </jqx-chart>
    <table style="width: 850px">
        <tr>
            <td style="padding-left: 50px">
                <p style="font-family: Verdana; font-size: 12px;">
                    Move the slider to rotate:
                </p>
                <jqx-slider jqx-settings="sliderAngleSettings" jqx-on-change="sliderStartAngleChange(event)">
                </jqx-slider>
            </td>
            <td>
                <p style="font-family: Verdana; font-size: 12px;">
                    Select the series type:
                </p>
                <jqx-drop-down-list jqx-settings="dropDownSeriesSettings" jqx-on-select="dropDownSeriesSelect(event)">
                </jqx-drop-down-list>
            </td>
        </tr>
        <tr>
            <td style="padding-left: 50px">
                <p style="font-family: Verdana; font-size: 12px;">
                    Move the slider to change the radius:
                </p>
                <jqx-slider jqx-settings="sliderRadiusSettings" jqx-on-change="sliderRadiusChange(event)">
                </jqx-slider>
            </td>
            <td>
                <p style="font-family: Verdana; font-size: 12px;">
                    Select color scheme:
                </p>
                <jqx-drop-down-list jqx-settings="dropDownColorsSettings" jqx-on-change="dropDownColorsChange(event)" id='dropDownColors'>
                </jqx-drop-down-list>
            </td>
        </tr>
    </table>
</body>
</html>
